package nl.gamayun.whohasit;

import java.util.Collection;
import java.util.List;


/**
 * 
 * Service to gather the information needed for the Who Has It App
 * 
 * @author pzw
 *
 */
public interface WhoHasItHandler
{
	/**
	 * The number of loans in the App
	 * 
	 * @return
	 */
	public int getNumberOfLoans();
	
	/**
	 * The number of loans in the App for a specific {@link TYPE}
	 * 
	 * @return
	 */
	public int getNumberOfLoansForType(TYPE type);
	
	/**
	 * The loan voor passed loanId 
	 * 
	 * @return {@link Loan}
	 */
	public Loan getLoan(long loanId);
	
	/**
	 * The newest loan 
	 * 
	 * @return {@link Loan}
	 */
	public Loan getNewestLoan();
	
	/**
	 * The oldest loan 
	 * 
	 * @return {@link Loan}
	 */
	public Loan getOldestLoan();
	
	/**
	 * The person where the most is lent from
	 * 
	 * @return
	 */
	public String getLentMostFrom();
	
	/**
	 * The person where the most is lent to
	 * 
	 * @return
	 */
	public String getLentMostTo();
	
	/**
	 * Get all loans 
	 * @return
	 */
	public Collection<Loan> getLoans();
	
	/**
	 * Get all loans
	 * @return
	 */
	public List<Loan> getAllLoans();
	
	/**
	 * Get all loans by TYPE
	 * @return
	 */
	public List<Loan> getAllLoansByType(TYPE type);
	
	/**
	 * Get all loans by loaner
	 * @return
	 */
	public List<Loan> getAllLoansByLoaner(String loanerName);

	/**
	 * Get all loans by loaner and type
	 * @return
	 */
	public List<Loan> getAllLoansByLoaner(String loanerName, TYPE type);
	
	/**
	 * Add loan to the List
	 * 
	 * @param loan
	 */
	public void addLoan(Loan loan);

	/**
	 * update loan to the List
	 * 
	 * @param loan
	 */
	public void updateLoan(Loan loan);

	/**
	 * Remove loan to the List
	 * 
	 * @param loan
	 */
	public void removeLoan(Loan loan);
	
	/**
	 * Things to do when Destroy of activity;
	 */
	public void onDestroy();
	
	/**
	 * The version of the database in the stored Handler
	 * @return
	 */
	public int getDatabaseVersion();
	
	/**
	 * The LoamAdapter that controls the loan list view
	 * @return
	 */
	public LoanAdapter getLoanAdapter();
}
